package com.ang.springboot.provider.topic;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicConfig {

    public final String queueMan = "topicQueueMan";
    public final String queueWoman = "topicQueueWoman";
    public final String key1 = "topic.man";
    public final String key2 = "topic.#";

    @Bean
    Queue topicQueueMan(){
        return new Queue(queueMan);
    }

    @Bean
    Queue topicQueueWoman(){
        return new Queue(queueWoman);
    }

    @Bean
    TopicExchange topicExchange(){
        return new TopicExchange("topicExchange");
    }

    @Bean
    Binding bindingTopicMan(){
        return BindingBuilder.bind(topicQueueMan()).to(topicExchange()).with(key1);
    }

    @Bean
    Binding bindingTopicWoman(){
        return BindingBuilder.bind(topicQueueWoman()).to(topicExchange()).with(key2);
    }
}
